package com.intelligent.ispc.utils;

/**
 * Created by Peter on 15/11/27.
 */
public enum DataColumns {
    SERIAL_NUMBER(1, "Serial Number"),
    CONFIG(2, "Config"),
    STATION_ID(3, "Station ID"),
    SITE_ID(4, "Site ID"),
    TEST_STATUS(5, "Test PASS/FAIL STATUS"),
    FAILING_TEST(6, "List of Failing Tests"),
    START_TIME(7, "Test Start Time"),
    STOP_TIME(8, "Test Stop Time"),
    TOTAL_TIME(9, "Total Test Time"),
    ERROR_MSG(10, "Error Message");

    private int index;
    private String code;

    DataColumns(int index, String code) {
        this.code = code;
        this.index = index;
    }

    public static DataColumns getValueOf(String code) {
        if (SERIAL_NUMBER.getCode().equals(code)) {
            return SERIAL_NUMBER;
        } else if (CONFIG.getCode().equals(code)) {
            return CONFIG;
        } else if (STATION_ID.getCode().equals(code)) {
            return STATION_ID;
        } else if (SITE_ID.getCode().equals(code)) {
            return SITE_ID;
        } else if (TEST_STATUS.getCode().equals(code)) {
            return TEST_STATUS;
        } else if (FAILING_TEST.getCode().equals(code)) {
            return FAILING_TEST;
        } else if (START_TIME.getCode().equals(code)) {
            return START_TIME;
        } else if (STOP_TIME.getCode().equals(code)) {
            return STOP_TIME;
        } else if (TOTAL_TIME.getCode().equals(code)) {
            return TOTAL_TIME;
        }  else if (ERROR_MSG.getCode().equals(code)) {
            return ERROR_MSG;
        }  else {
            return null;
        }
    }

    public static DataColumns getValueOf(int index) {
        switch (index) {
            case 1:
                return SERIAL_NUMBER;
            case 2:
                return CONFIG;
            case 3:
                return STATION_ID;
            case 4:
                return SITE_ID;
            case 5:
                return TEST_STATUS;
            case 6:
                return FAILING_TEST;
            case 7:
                return START_TIME;
            case 8:
                return STOP_TIME;
            case 9:
                return TOTAL_TIME;
            case 10:
                return ERROR_MSG;
            default:
                return null;
        }
    }

    public String getCode() {
        return code;
    }

    public int getIndex() {
        return index;
    }
}
